#include "starthub.h"
#include "qtquick2applicationviewer.h"
#include "connectmanager.h"
#include "qtquick2applicationviewer.h"


StartHub::StartHub(QObject *parent) :
    QObject(parent)
{
    qDebug()<<QDir::currentPath();
    QtQuick2ApplicationViewer* viewer = new QtQuick2ApplicationViewer;
    QQmlContext* qmlAsContext =  viewer->engine()->rootContext();
    viewer->setMainQmlFile(QStringLiteral("qml/main.qml"));
    viewer->showExpanded();

    ConnectManager* O_CM = new ConnectManager;
    connect(O_CM,&ConnectManager::hostStatusInfo,
            [=](const bool&_s)
    {
        qmlAsContext->setContextProperty("status",QVariant(_s));
        if(!_s)
            QSound::play("bell.wav");
    });


    QTimer *timer = new QTimer;
    //connect(timer, &QTimer::timeout,&O_CM, &ConnectManager::aboutHost);
    connect(timer, &QTimer::timeout,
            [=]()
    {
        O_CM->aboutHost();
    });
    timer->start(3000);

}
